package com.cn.springcloudapi.controller;

import com.cn.springcloudapi.model.URole;
import com.cn.springcloudapi.utils.redis.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.cn.springcloudapi.inter.TestFallbackApi;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
public class TestControllerApi {
	@Autowired
	TestFallbackApi testFallbackApi;
	@RequestMapping("/test")
	@ResponseBody
	public String test(){
		String id = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getSessionId();
		System.out.println("api:"+id);
		return id;
	}
	@RequestMapping("/set")
	public String getHi() {
		RedisUtil.set("user","cx",new Long(60));
		System.out.println("welcomeTest");
		String name="sss";
		URole uRole =new URole();
		uRole.setId(1L);
		uRole.setName("sss");
		return testFallbackApi.getHi(name,uRole);
	}

}
